import moment from "moment";


const paramsToQueryString = (params) => {
  return '?' + Object.keys(params).map(key => key + '=' + (params[key] || '') ).join('&');
}

/**
 * 使用moment把字符串格式时间转换为指定格式
 * @param {*} dateTime 
 */
const formatTime = (dateTime) => {
  if(!dateTime && dateTime !== ''){
    return moment(dateTime).format('YYYY-MM-DD HH:mm:ss');
  }
  return "";
}

const Tools = {
    paramsToQueryString,
    formatTime
}

export default Tools;